// pages/akhexiao/akhexiao.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    EMPLOYEE_ID:'',
    openid:'',
    jiami:'',
    OPEN_ID:'',
    session_key:'',
  },


  saomiao(){

    this.setData({
      EMPLOYEE_ID: app.globalData.mealsList,
      openid: app.globalData.openid,

      jiami: app.globalData.jiami,
      OPEN_ID: app.globalData.openid,
      session_key: app.globalData.session_key,
  
      
    });

    console.log(this.data.OPEN_ID);

    let that = this


    wx.scanCode({ //扫描API
      success(res) {
        console.log(res);
        console.log(res.result);
        if (res.result!='') {
          wx.request({
            url:app.globalData.interface+'/hanzhong/API_7107_UserLogo', 
            method:'POST',
             data: {
              CODE:res.result,
              KEY:'xianjgjKey9999',
              EMPLOYEE_ID:that.data.EMPLOYEE_ID,
              OPEN_ID: that.data.OPEN_ID, //用户OPEN_ID
              session_key:that.data.session_key,
              OPEN_UUID:that.data.jiami
             },
             header:{
               'content-type':'application/x-www-form-urlencoded'
             },
             success:res=> {
               console.log(res)
               wx.showToast({
                title: res.data.data,
                duration: 2000
              })
             }
           })
             //扫描成功
             console.log(res) //输出回调信息
             wx.showToast({
               title: '激活成功',
               duration: 2000
             })
        } else{

          wx.showToast({
            title: '扫描失败请重新扫码',
            duration: 1000
          })

        }
       


          // this.ticket()
        // }
      }
    })
  
  },













  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(e) {
    console.log(e.data);

    this.setData({
      EMPLOYEE_ID:e.data,
      EMPLOYEE_ID: app.globalData.mealsList,
      openid: app.globalData.openid,

      jiami: app.globalData.jiami,
      OPEN_ID: app.globalData.openid,
      session_key: app.globalData.session_key,
  
    })

  


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})